Add TimeZone header support to REST API (#17344)#17387
Add TimeZone header support to REST API (#17344)#17387Lexert19 wants to merge 4 commits intoapache:masterfrom
Conversation
|
Another question, why did you pick |
|
And consider add some example in https://github.com/apache/iotdb/tree/master/example/rest-java-example/src/main/java/org/apache/iotdb? |
dacddb6 to
4eb0e06
Compare
|
Hi @HTHou, thank you for the review! I've updated the PR:
|
4eb0e06 to
a286e68
Compare
|
Hi @Lexert19, could you please share this new feature in the dev mail list? |
There was a problem hiding this comment.
Pull request overview
This PR introduces request-level time zone handling for the REST APIs by parsing a time zone HTTP header in the REST authorization filter, storing it on the session, and then using the session ZoneId when parsing SQL statements so time literals (and time-based semantics like GROUP BY window alignment) respect the client-provided time zone.
Changes:
- Parse a time zone header in
AuthorizationFilterand set the resolvedZoneIdinto theSessionManagersession (reject invalid values with HTTP 400). - Use the current session
ZoneId(instead ofZoneId.systemDefault()) when generating statements in REST v1/v2 and Grafana REST implementations (and table REST statement creation). - Add integration tests and update Java REST examples to demonstrate header usage.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBRestServiceIT.java | Adds IT coverage for valid/invalid time zone headers on REST v1/v2 query and nonQuery flows. |
| external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/impl/RestApiServiceImpl.java | Uses session ZoneId when parsing SQL for v2 query/nonQuery endpoints. |
| external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v2/impl/GrafanaApiServiceImpl.java | Uses session ZoneId when parsing Grafana SQL endpoints in v2. |
| external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/impl/RestApiServiceImpl.java | Uses session ZoneId when parsing SQL for v1 query/nonQuery endpoints. |
| external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/impl/GrafanaApiServiceImpl.java | Uses session ZoneId when parsing Grafana SQL endpoints in v1. |
| external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/table/v1/impl/RestApiServiceImpl.java | Uses the client session’s ZoneId when parsing table-model SQL statements. |
| external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/AuthorizationFilter.java | Parses Time-Zone header into ZoneId, aborts request on invalid values, and supplies it to the session. |
| example/rest-java-example/src/main/java/org/apache/iotdb/TableHttpsExample.java | Adds a table REST query example that includes a time zone header. |
| example/rest-java-example/src/main/java/org/apache/iotdb/TableHttpExample.java | Adds a table REST query example that includes a time zone header and uses slf4j logging. |
| example/rest-java-example/src/main/java/org/apache/iotdb/HttpsExample.java | Adds a REST query example that includes a time zone header. |
| example/rest-java-example/src/main/java/org/apache/iotdb/HttpExample.java | Adds a REST “queryWithTimeZone” example (but currently missing the actual header). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBRestServiceIT.java
Show resolved
Hide resolved
integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBRestServiceIT.java
Show resolved
Hide resolved
...rvice-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/AuthorizationFilter.java
Show resolved
Hide resolved
...rvice-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/filter/AuthorizationFilter.java
Show resolved
Hide resolved
example/rest-java-example/src/main/java/org/apache/iotdb/HttpExample.java
Show resolved
Hide resolved
f0c638e to
1c7b835
Compare
|
Hi @HTHou, i have updated the PR to address all the feedback: |
Description
This PR adds support for the TimeZone header in REST API. The header is parsed in AuthorizationFilter and the time zone is set in the session. Integration tests are added to verify correct handling of valid and invalid time zones.
Closes #17344
This PR has:
for an unfamiliar reader.
for code coverage.
Key changed/added classes (or packages if there are too many classes) in this PR